package com.botann.projects.utils;


import com.botann.projects.utils.wechat.pay.WechatPayUtil;
import com.botann.projects.utils.wechat.pay.WechatPayUtil;
import org.apache.commons.codec.digest.DigestUtils;

/**
 * stock
 * MainTest
 * Created by 刘山国 on 2019/4/19.
 * Copyright (c) 2017 伯坦科技. All rights reserved
 */
public class MainTest {

    public static void main(String[] args) throws Exception {
//        String filepath="/Users/liushanguo/Desktop";

        //生成公钥和私钥文件
//        RSAEncrypt.genKeyPair(filepath);

//        System.out.println("--------------公钥加密私钥解密过程-------------------");
//        String plainText="ihep_公钥加密私钥解密";

//        String privateKeyStr = RSAEncrypt.loadKeyByFilePath(filepath + RSAEncrypt.kPrivate_Key_File);
//        String publicKeyStr = RSAEncrypt.loadKeyByFilePath(filepath + RSAEncrypt.kPublic_Key_File);

//        String privateKeyStr = RSAEncrypt.loadKeyByFilePath(filepath + "/private.pem");
//        String publicKeyStr = RSAEncrypt.loadKeyByFilePath(filepath + "/public.pem");

//        String privateKeyStr = RSAEncrypt.loadKeyByFilePath(filepath + "/rsa_private_key.pem");
//        String publicKeyStr = RSAEncrypt.loadKeyByFilePath(filepath + "/rsa_public_key.pem");

//        String privateKeyStr1 = "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC+UptQh+HJ8nHwHfIYkqURedG22fYXJ7xz1rlWzHXlPLXK/0yoWWjwwigC03gpd2pAtS9EGp+NzBwz04+yf6YYKH1octNbf/Jk9gd2aBrrFgyXSQhFvto6Tjvzxrh8VCgGRBAYK6zU9GFxIZ3tZgysFngZ4QUB+/kj1Ca50waAkZTVv3+CD7egXPz61CfF7+k8vUdF+1IT4UqCcIQwZqAdceLPtYfbo12ujIsC1UrWJoTbcxT/L/HV3/WPbGwx0xVlWJLyK5Rg2gXidls4Oie+r30QRdZSQ/EXJwzgBP4SPItEQ1DmMvjzVByLdExbCh5OATimqMn1qMO6qxuYrVFNAgMBAAECggEAX9SqXb89wniwRC5f412bfhQvs3lGP1yDuHQq+Hi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iIGsl3L+2dzlb4QCcmzf8HKP3Z9B/lrfouPXHxJxnCIk3KWR579ni2NHUJUQW6wm/AJNqZcJqg/bOJTjfoFrM95Z6V0Y4";
//        String publicKeyStr1 = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvlKbUIfhyfJx8B3yGJKlEXnRttn2Fye8c9a5Vsx15Ty1yv9MqFlo8MIoAtN4KXdqQLUvRBqfjcwcM9OPsn+mGCh9aHLTW3/yZPYHdmga6xYMl0kIRb7aOk4788a4fFQoBkQQGCus1PRhcSGd7WYMrBZ4GeEFAfv5I9QmudMGgJGU1b9/gg+3oFz8+tQnxe/pPL1HRftSE+FKgnCEMGagHXHiz7WH26NdroyLAtVK1iaE23MU/y/x1d/1j2xsMdMVZViS8iuUYNoF4nZbODonvq99EEXWUkPxFycM4AT+EjyLRENQ5jL481Qci3RMWwoeTgE4pqjJ9ajDuqsbmK1RTQIDAQAB";


//        System.out.println("私钥1:");
//        System.out.println(privateKeyStr1);
//        System.out.println("私钥2:");
//        System.out.println(privateKeyStr);
//        System.out.println("公钥对1:");
//        System.out.println(publicKeyStr1);
//        System.out.println("公钥对:");
//        System.out.println(publicKeyStr);


        //公钥加密过程
//        String cipher = RSAEncrypt.encrypt(plainText, RSAEncrypt.RSAKeyType.PUBLIC,publicKeyStr);
//        //私钥解密过程
//        String restr = RSAEncrypt.decrypt(cipher, RSAEncrypt.RSAKeyType.PRIVATE,privateKeyStr);
//        System.out.println("原文："+plainText);
//        System.out.println("加密："+cipher);
//        System.out.println("解密："+restr);
//        System.out.println();
//
//        System.out.println("--------------私钥加密公钥解密过程-------------------");
//        plainText="ihep_私钥加密公钥解密";
//        //私钥加密过程
//        cipher=RSAEncrypt.encrypt(plainText, RSAEncrypt.RSAKeyType.PRIVATE,privateKeyStr);
//        //公钥解密过程
//        restr=RSAEncrypt.decrypt(cipher, RSAEncrypt.RSAKeyType.PUBLIC,publicKeyStr);
//        System.out.println("原文："+plainText);
//        System.out.println("加密："+cipher);
//        System.out.println("解密："+restr);
//        System.out.println();
//
//        System.out.println("---------------私钥签名过程------------------");
//        String content="ihep_这是用于签名的原始数据";
//        String signstr=RSASignature.sign(content,privateKeyStr);
//        System.out.println("签名原串："+content);
//        System.out.println("签名串："+signstr);
//        System.out.println();
//
//        System.out.println("---------------公钥校验签名------------------");
//        System.out.println("签名原串："+content);
//        System.out.println("签名串："+signstr);
//
//        System.out.println("验签结果："+RSASignature.doCheck(content, signstr, publicKeyStr));
//        System.out.println();

//        test();
//        testTime();

//        new TestOBj();

//        base64();


//        System.out.println(String.format("%.0f",1.69));
        String toS = "appId=wx1dcdc9eb5192990a&nonceStr=jq558krv4lvk2t8yq9t8exi1flx88bau&package=prepay_id=wx21012157190033d8c7b7bad51413810800&signType=MD5&timeStamp=1569000117";
        String s = DigestUtils.md5Hex(WechatPayUtil.getContentBytes(toS, "utf-8"));
//        String s = MD5Utils.md5(toS);
        System.out.println(s);

    }


//    public static void main() {
//
//    }


}
